#ubuntu的内核源码树，如果要编译在ubuntu中安装的模块就打开这2个
# KERN_VER = $(shell uname -r)
# KERN_DIR = /lib/modules/$(KERN_VER)/build	

# 内核开发中，在顶层 Makefile 设置了这2个，
# arm64可以作为Makefile参数传入，传入以后Makefile内部进行判断， arm arm64 mips不同的编译参数
# 在编译的时候，顶层 makefile 会去取这个2个变量
export ARCH=arm64
# export C_INCLUDE_PATH=/usr/include
export CROSS_COMPILE=/mnt/work2/rk3566_3568_sourcecode/prebuilts/gcc/linux-x86/aarch64/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-

# android 的交叉编译器，就是gcc linux的 
export arm64_gcc=/mnt/work2/rk3566_3568_sourcecode/prebuilts/gcc/linux-x86/aarch64/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc	



# rk3568开发板的linux内核的源码树目录
KERN_DIR=/mnt/work2/rk3566_3568_sourcecode/kernel

#   把 leds-leds_rk3568.c 编译为目标 leds_rk3568.ko      obj表示 object   m表示module 
# obj-m	+= leds_rk3568.o
obj-m	+= rk3568_gpiod_apil14.o


APP = gpioctrl


# obj-$(PLATFORM_LEDS_RK3568) += leds_rk3568.o
# PWD?=$(shell pwd)                     Makefile 路径， 驱动源码路径     等价于  `pwd`

all:
#  命令 make  modules     -C 改变目录到内核源码里面去， M    理解Module   - makefile和源码的路径
#	make -C $(KERN_DIR) M=`pwd` modules
#	$(arm64_gcc) -o read.o read.c -static
#	$(arm64_gcc) -o write.o write.c -static
#	$(arm64_gcc) -o gpioctrl08_mem.o gpioctrl08_mem.c -static
	aarch64-linux-gnu-gcc $(APP).c -o $(addsuffix .out, $(APP))

# 验证是32还是64位cpu: 
# https://www.cnblogs.com/wutaotaosin/articles/16490218.html


.PHONY: clean
clean:
# 	make -C $(KERN_DIR) M=`pwd` modules clean
	rm -rf *.o  *.ko *.mod.o *.mod.c *.symvers *.order a.out $(addsuffix .out, $(APP))

